Skip to content

Run the Postgres store tests in CI on Postgres 16 and 17 - #729

Open
adityamishra-hydradb wants to merge 2 commits into
mainfrom
adityamishra/oss-136-pg-ci
Open

adityamishra-hydradb wants to merge 2 commits into
mainfrom
adityamishra/oss-136-pg-ci

Conversation

@adityamishra-hydradb

@adityamishra-hydradb adityamishra-hydradb commented Dec 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #706. A new CI job, postgres, builds pg_hydradb from a pinned hydradb commit and runs the Postgres store tests of both SDKs on Postgres 16 and 17. Before this, CI skipped those tests.
AGENTS.md now lets a schema draft read a store's own catalog and registry, never user rows.

Implementation details

Door: two-way
CI and contributor guidance only. No code, API, or stored shape changes.

Cleanup: none

What to delete:

Decisions

These were the open questions of #706 and its stack (#707, #708, #709, #712, #710). As maintainers, we decided them:

  • CI builds pg_hydradb itself. The job uses no prebuilt image and publishes nothing to a registry. .github/pg-hydradb/Dockerfile builds the extension in postgres:<major>-bookworm from hydradb 58390740c6d7 (tag v0.5.0, HYDRADB_REF in ci.yml) with Rust 1.99.0, the hydradb toolchain. Its output stage holds only pg_hydradb.so, the control file, and the SQL file.
  • The job caches those files with actions/cache, keyed on the Postgres major version, HYDRADB_REF, and the Dockerfile hash. On a cache hit, Docker builds nothing: the job copies the files into a stock postgres:<major>-bookworm container and starts it. To move to a newer pg_hydradb, change HYDRADB_REF.
  • Matrix: Postgres 16 and 17. The job installs the wheel with [dev,kuzu,postgres], runs tests/test_pg_hydradb_store.py, and runs test/pgHydradbStore.test.ts from source. The test imports src/, so the job needs no TypeScript bundle; SELFGRAPH_TEST_PREBUILT=1 skips the build in the global setup.
  • Fork PRs: the job is in ci.yml under pull_request, with contents: read and no secrets. It never uses pull_request_target. A fork PR can read the cache that main saved. Anything it saves stays scoped to its own ref, so it cannot change what main or other PRs restore.
  • Drivers stay as shipped: asyncpg (asyncpg>=0.30) for Python, and node-postgres pg as an optional peer dependency for TypeScript. No code change.
  • check_answerable stays refused on this store with unsupported_read, because it must read every row. No version that checks only seed candidates (YAGNI). docs/backends.md already lists it under "What is refused".
  • AGENTS.md: "Schema drafts read table metadata the caller passes, never rows or a database" now allows a store's own catalog and registry, such as the pg_hydradb registry tables that PgHydraDBStore.draft_schema reads. A draft still never reads user rows. The test section names the postgres job and SG_PG_HYDRADB_URI.

Validation

CI on this PR. Both runs show the server version, so the extension loaded through the fixture's CREATE EXTENSION:

Run Postgres Extension Job time pytest tests/test_pg_hydradb_store.py vitest test/pgHydradbStore.test.ts
cold 16.16 cache miss; docker build 1m37s (cargo 60s) 2m30s 9 passed, 0 skipped 11 passed (11)
cold 17.12 cache miss; docker build 2m13s (cargo 1m20s) 2m47s 9 passed, 0 skipped 11 passed (11)
cached 16.16 cache hit; docker build step skipped 33s 9 passed, 0 skipped 11 passed (11)
cached 17.12 cache hit; docker build step skipped 39s 9 passed, 0 skipped 11 passed (11)
  • Before this PR, no workflow on main set SG_PG_HYDRADB_URI, so every CI job skipped these tests.
  • Local: the same docker build --output for Postgres 16 produced lib/pg_hydradb.so, extension/pg_hydradb.control, and extension/pg_hydradb--0.1.0.sql.
  • review-precheck passes. No new tests; the job runs the existing gated tests.

Limits

  • The job pins one hydradb commit. A newer pg_hydradb is not tested until someone moves HYDRADB_REF.
  • Postgres 18 is not in the matrix. The store passed on 18.7 locally (see #708).

Linked issue

Refs #706 (closed by the merged stack).

AI Assistance

Model Effort
Claude Opus 5.5 High

Checklist

  • Implements an issue a maintainer has /approved.
  • Small and scoped to that issue.
  • New errors have a code and hint, the same on API, CLI, and MCP in both SDKs (see AGENTS.md).
  • Breaking changes described below, or none.

Breaking changes

None.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityamishra-hydradb <[email protected]>
@adityamishra-hydradb

Copy link
Copy Markdown
Collaborator Author

@hydra-mira-review review

@hydra-mira-review

hydra-mira-review Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Mira score 5/5 · 🟢 Good to merge

  • No findings, nothing missing outside this PR, and no high-risk change.

Postgres store tests now run in CI for both SDKs on Postgres 16 and 17. The job builds and caches a pinned extension, while contributor guidance permits schema drafts to read store catalogs and registries.

How this PR works · 4 changes, 2 medium risk, 2 low risk

Postgres store integration tests previously skipped in CI because no job supplied a database with the extension installed. This PR builds a pinned extension, caches its files, and runs both SDK suites on Postgres 16 and 17. Contributor guidance also permits schema drafts to read store catalogs and registries while forbidding user rows.

1. Build the Postgres extension from pinned source · 🟠 medium risk · .github/pg-hydradb/Dockerfile +1

CI now builds its own Postgres extension rather than leaving these integration tests without a database. The Dockerfile compiles pinned hydradb source with Rust 1.99.0 for the selected Postgres major.

Risk: An incompatible source pin or build dependency prevents the Postgres CI job from reaching either SDK suite.

Check:

  • Build each Postgres major without a cache and confirm the exported files support the fixture's CREATE EXTENSION.

In Dockerfile:1-19, ci.yml:341-342, ci.yml:352-355.

2. Reuse extension files and start a matching Postgres server · 🟠 medium risk · .github/workflows/ci.yml

Repeated CI runs can reuse the compiled extension without building Docker images. The job copies the files into a stock Postgres container, starts it, and checks readiness.

Risk: Incorrect cached files or startup paths leave both SDK suites unable to load the extension or connect to Postgres.

Check:

  • Restore an exact cache hit and confirm Docker compilation is skipped while the database-backed tests still execute.

In ci.yml:347-362.

3. Run both SDK store suites on Postgres 16 and 17 · 🟢 low risk · .github/workflows/ci.yml

Both SDKs now receive dedicated database-backed CI coverage on two Postgres versions. The new postgres job supplies the connection URI that previously left their integration cases skipped.

Risk: Incorrect dependency installation or test environment settings cause CI failures or leave database-backed cases skipped.

Check:

  • Confirm both matrix entries execute the database-backed cases rather than reporting skips.
  • Confirm the TypeScript suite passes with the bundle build disabled.

In ci.yml:332-344, ci.yml:363-385.

4. Supporting changes: clarify schema drafts and test guidance · 🟢 low risk · AGENTS.md

Contributor guidance now permits schema drafts to read a store's catalog and registry, while continuing to forbid user rows. AGENTS.md also documents the Postgres test gate and CI matrix.

Risk: Ambiguous guidance could lead contributors to permit user-row reads when implementing schema drafts.

Check:

  • Check that the revised invariant clearly distinguishes store metadata from user rows.

In AGENTS.md:20, AGENTS.md:97.

Requirement check · 8 met · from the PR description
  • ✅ Run the existing Postgres store tests for both SDKs on Postgres 16 and 17 (met). .github/workflows/ci.yml:332-385 defines both matrix entries, supplies SG_PG_HYDRADB_URI, and invokes both targeted suites.
  • ✅ Build the extension from the pinned hydradb commit using Rust 1.99.0, without publishing an image (met). The workflow pins HYDRADB_REF; .github/pg-hydradb/Dockerfile compiles it with Rust 1.99.0 and exports only extension files.
  • ✅ Cache extension files by Postgres major, hydradb commit, and Dockerfile hash; skip compilation on an exact hit (met). .github/workflows/ci.yml:347-355 defines that cache key and guards docker build with the cache-hit output.
  • ✅ Test the Python wheel with its required extras and run TypeScript from source without building a bundle (met). The workflow installs [dev,kuzu,postgres]; the TypeScript test imports src, and globalSetup.setup returns when SELFGRAPH_TEST_PREBUILT=1.
  • ✅ Run fork PRs with read-only repository permissions, no secrets, and no pull_request_target trigger (met). The workflow uses pull_request and contents: read; the new job references no secrets and uses the standard Actions cache.
  • ✅ Keep the shipped drivers and existing store behavior unchanged (met). Changes are confined to CI and guidance; pyproject.toml retains asyncpg>=0.30, and TypeScript retains optional peer dependency pg.
  • ✅ Keep check_answerable refused and documented for the Postgres store (met). No SDK code changes; docs/backends.md already lists check_answerable among operations refused with unsupported_read.
  • ✅ Allow schema drafts to read store catalogs and registries, but never user rows, and document the Postgres CI gate (met). AGENTS.md:20 documents the job and URI; AGENTS.md:97 states the revised metadata-only boundary.

Comment @hydra-mira-review help for commands.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityamishra-hydradb <[email protected]>
@adityamishra-hydradb

Copy link
Copy Markdown
Collaborator Author

@hydra-mira-review review

1 similar comment
@adityamishra-hydradb

Copy link
Copy Markdown
Collaborator Author

@hydra-mira-review review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant